﻿using B.Z.BasicData.Domain.Entity.Authorize;
using B.Z.BasicData.Domain.Entity.Excused;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.Z.BasicData.Infrastructure
{
    public class UserDbContext : DbContext
    {
        public UserDbContext(DbContextOptions options) : base(options)
        {
        }
        public DbSet<T_User> T_Users { get; set; }
        public DbSet<T_Province> T_Provinces { get; set; }
        public DbSet<T_City> T_Cities { get; set; }
        public DbSet<T_Contry> T_Contries { get; set; }
        public DbSet<T_Role> T_Roles { get; set; }
        public DbSet<T_UserRole> T_UserRoles { get; set; }
        public DbSet<T_Menu> T_Menus { get; set; }
        public DbSet<T_RoleMenu> T_RoleMenus { get; set; }
        public DbSet<T_Department> T_Departments { get; set; }
        public DbSet<T_ExcusedType> T_ExcusedTypes { get; set; }
        public DbSet<T_Excused> T_Excuseds { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<T_User>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<T_Role>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<T_Menu>().HasQueryFilter(p => !p.IsDelete);
            modelBuilder.Entity<T_Excused>().HasQueryFilter(p => !p.IsDelete);
        }
    }
}
